#include<vector>
#include<iostream>
#include<algorithm>
using std::vector;

class Solution {
public:
    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        std::sort(candidates.begin(), candidates.end());
        vector<vector<int>> result;
        for (int i = 0; i < candidates.size(); i++) {
            if (candidates[i] > target) break;
            vector<int> curPath = {candidates[i]};
            this->search(result, candidates, i, target-candidates[i], curPath);
        }
        return result;
    }

    void search(vector<vector<int>>& res, vector<int>& candidates, int left, int target, vector<int> path) {
        if (target == 0) {
            res.push_back(path);
            return;
        }
        for (int i = left; i < candidates.size(); i++) {
            if (candidates[i] > target) break;
            vector<int> path2(path);
            path2.push_back(candidates[i]);

            this->search(res, candidates, i, target-candidates[i], path2);
        }

    }
};


int main() {
    vector<int> input = {};
    int n;
    while (std::cin >> n) {
        input.push_back(n);
    }
    std::cout << "input: \n";
    for (auto k: input) std::cout << k << " ";
    std::cout << "\n";
    

    auto res = Solution().combinationSum(input, 7);
    std::cout << "result is below \n";
    for (auto p : res) {
        for (auto n : p) {
            std::cout << n << ",";
        }
        std::cout << "\n";
    }
    return 0;


}